/*
 * PDLogger
 * 
 * Copyright (c) 2012, Zoujie Wu <yibn2008@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 *   * Redistributions of source code must retain the above copyright notice, this 
 *     list of conditions and the following disclaimer.
 *   
 *   * Redistributions in binary form must reproduce the above copyright notice, 
 *     this list of conditions and the following disclaimer in the documentation 
 *     and/or other materials provided with the distribution.
 *   
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* $Id$ */

#ifndef PDL_OUTPUT_H
#define PDL_OUTPUT_H

/* define log output constants */
#define PDL_FORMAT_INDENT	2
#define PDL_MAX_NEST_LAYER	3
#define PDL_DATE_FORMAT		"Y-m-d H:i:s"

/* define log output format */
#define PDL_FM_CUSTOM		(1<<0L)			/* User custom handler to format records */
#define PDL_FM_XML			(1<<1L)
#define PDL_FM_TEXT			(1<<2L)

typedef int (*pdl_gen_log_header_t) (char **header, long date, int period TSRMLS_DC);

/* define log output internal API */
PDL_API int pdl_format_zval(char **str, zval *data, zend_bool with_eol, int indent, int layer TSRMLS_DC);
PDL_API zval* pdl_format_xml(TSRMLS_D);
PDL_API zval* pdl_format_text(TSRMLS_D);
PDL_API zval* pdl_format_custom(TSRMLS_D);
PDL_API zval* pdl_export(TSRMLS_D);
PDL_API void pdl_write_records(TSRMLS_D);

/* {{{ ARG_INFO
 */
ZEND_BEGIN_ARG_INFO(pdl_format_arginfo, 0)
	ZEND_ARG_INFO(0, format)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(pdl_format_handler_arginfo, 0, 0, 1)
	ZEND_ARG_INFO(0, record_cb)
	ZEND_ARG_INFO(0, header_cb)
	ZEND_ARG_INFO(0, delimiter)
ZEND_END_ARG_INFO()
/* }}} */

/* define log output API */
PHP_FUNCTION(pdl_format);
PHP_FUNCTION(pdl_format_handler);
PHP_FUNCTION(pdl_export);
PHP_FUNCTION(pdl_write);

#endif	/* PDL_OUTPUT_H */


/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: noet sw=4 ts=4 fdm=marker
 * vim<600: noet sw=4 ts=4
 */
